package inabit.compiler.lexical.automaton.transitions;

import inabit.compiler.lexical.automaton.Transition;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**Represents a type of transition that accept only the specified characters at constructor*/
/**@author Rafael Rocha*/
public class InclusiveTransition extends Transition{
	private Set<Character> includedChars;
	
	public InclusiveTransition(String source, String target, char... chars) {
		super(source, target);
		this.includedChars = new HashSet<Character>();
		for(char c : chars) {
			this.includedChars.add(c);
		}
	}
	public InclusiveTransition(String source, String target, Collection<Character> chars) {
		super(source, target);
		this.includedChars = new HashSet<Character>();
		this.includedChars.addAll(chars);
	}
	@Override
	public boolean acceptTransition(char c) {
		return includedChars.contains(c);
	}

}
